Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bin/lint-markdown: Use markdown-lint-check executable directly if present #759

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

doshitan
Copy link
Contributor

@doshitan doshitan commented Sep 30, 2024

Changes

Don't force a download/allow alternate tooling install methods.

Testing

Adding -t onto xargs to print what it's executing.

With executable

❯ which markdown-link-check 
/nix/store/frf2r70z030wz2cm1q9s136id35b11cx-markdown-link-check-3.12.1/bin/markdown-link-check

❯ make lint-markdown       
./bin/lint-markdown
sh -c 'markdown-link-check --config .github/workflows/markdownlint-config.json ./.github/pull_request_template.md'

FILE: ./.github/pull_request_template.md
  [✓] https://www.cockos.com/licecap/

  1 links checked.
sh -c 'markdown-link-check --config .github/workflows/markdownlint-config.json ./.github/workflows/README.md'

FILE: ./.github/workflows/README.md
  [✓] https://docs.github.com/en/actions/using-workflows/reusing-workflows
  [✓] https://github.com/navapbc/template-infra/blob/main/.github/workflows/ci-app-vulnerability-scans.yml
  [✓] file:///home/doshitan/projects/template-infra/docs/infra/pull-request-environments.md
  [✓] file:///home/doshitan/projects/template-infra/.github/workflows/ci-app-pr-environment-checks.yml
  [✓] https://github.com/navapbc/template-infra/blob/main/.github/workflows/ci-app-pr-environment-destroy.yml
  [✓] ./ci-docs.yml
  [✓] ./markdownlint-config.json
  [✓] ./ci-infra.yml
  [✓] https://github.com/navapbc/template-infra/blob/main/.github/workflows/cd-app.yml
  [✓] ./deploy.yml
  [✓] ./database-migrations.yml
  [✓] ./build-and-publish.yml
  [✓] ./check-ci-cd-auth.yml

  13 links checked.
sh -c 'markdown-link-check --config .github/workflows/markdownlint-config.json ./LICENSE.md'

...and so on

Without executable

Now the npx route is broken on my system, but to show the commands:

❯ which markdown-link-check
/usr/bin/which: no markdown-link-check in [...]

❯ make lint-markdown                                                                                                                                                                                               
./bin/lint-markdown                                                                                                                                                                                                
sh -c 'npx markdown-link-check --config .github/workflows/markdownlint-config.json ./.github/pull_request_template.md'                                                                                             
npm WARN exec The following package was not found and will be installed: markdown-link-check                                                                                                                       
npm WARN EBADENGINE Unsupported engine {                                                                                                                                                                           
npm WARN EBADENGINE   package: '[email protected]',                                                                                                                                                                 
npm WARN EBADENGINE   required: { node: '>=18' },                                                                                                                                                                  
npm WARN EBADENGINE   current: { node: 'v16.15.0', npm: '8.5.5' }                                                                                                                                                  
npm WARN EBADENGINE }                                                                                                                                                                                              
npm WARN EBADENGINE Unsupported engine {                                                                                                                                                                           
npm WARN EBADENGINE   package: '[email protected]',                                                                                                                                                                    
npm WARN EBADENGINE   required: { node: '>= 18' },                                                                                                                                                                 
npm WARN EBADENGINE   current: { node: 'v16.15.0', npm: '8.5.5' }                                                                                                                                                  
npm WARN EBADENGINE }                                                                                                                                                                                              
npm WARN EBADENGINE Unsupported engine {                                                                                                                                                                           
npm WARN EBADENGINE   package: '[email protected]',                                                                                                                                                                    
npm WARN EBADENGINE   required: { node: '>=18.17' },                                                                                                                                                               
npm WARN EBADENGINE   current: { node: 'v16.15.0', npm: '8.5.5' }                                                                                                                                                  
npm WARN EBADENGINE }                                                                                                                                                                                              
npm WARN EBADENGINE Unsupported engine {                                                                                                                                                                           
npm WARN EBADENGINE   package: '[email protected]',                                                                                                                                                                    
npm WARN EBADENGINE   required: { node: '>=18.17' },                                                                                                                                                               
npm WARN EBADENGINE   current: { node: 'v16.15.0', npm: '8.5.5' }                                                                                                                                                  
npm WARN EBADENGINE }                                                                                                                                                                                              
npm WARN EBADENGINE Unsupported engine {                                                                                                                                                                           
npm WARN EBADENGINE   package: '[email protected]',                                                                                                                                                            
npm WARN EBADENGINE   required: { node: '>=18' },                                                                                                                                                                  
npm WARN EBADENGINE   current: { node: 'v16.15.0', npm: '8.5.5' }                                                                                                                                                  
npm WARN EBADENGINE }                                                                                                                                                                                              
npm WARN EBADENGINE Unsupported engine {                                                                                                                                                                           
npm WARN EBADENGINE   package: '[email protected]',                                                                                                                                                            
npm WARN EBADENGINE   required: { node: '>=18' },                                                                                                                                                                  
npm WARN EBADENGINE   current: { node: 'v16.15.0', npm: '8.5.5' }    
npm WARN EBADENGINE }                                                                                                                                                                            12:09:11 [100/363]
/home/doshitan/.npm/_npx/3c3b53b86e3a61f2/node_modules/undici/lib/web/fetch/response.js:527                                                                                                                        
  ReadableStream                                                                                                                                                                                                   
  ^                                                                                                                                                                                                                
                                                                                                                                                                                                                   
ReferenceError: ReadableStream is not defined                                                                                                                                                                      
    at Object.<anonymous> (/home/doshitan/.npm/_npx/3c3b53b86e3a61f2/node_modules/undici/lib/web/fetch/response.js:527:3)                                                                                          
    at Module._compile (node:internal/modules/cjs/loader:1105:14)                                                                                                                                                  
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)                                                                                                                                    
    at Module.load (node:internal/modules/cjs/loader:981:32)                                                                                                                                                       
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)                                                                                                                                             
    at Module.require (node:internal/modules/cjs/loader:1005:19)                                                                                                                                                   
    at require (node:internal/modules/cjs/helpers:102:18)                                                                                                                                                          
    at Object.<anonymous> (/home/doshitan/.npm/_npx/3c3b53b86e3a61f2/node_modules/undici/lib/web/fetch/index.js:11:5)                                                                                              
    at Module._compile (node:internal/modules/cjs/loader:1105:14)                                                                                                                                                  
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)                                                                                                                                    
sh -c 'npx markdown-link-check --config .github/workflows/markdownlint-config.json ./.github/workflows/README.md'                                                                                                  
/home/doshitan/.npm/_npx/3c3b53b86e3a61f2/node_modules/undici/lib/web/fetch/response.js:527                                                                                                                        
  ReadableStream                                                                                                                                                                                                   
  ^                                                                                                                                                                                                                
                                                                                                                                                                                                                   
ReferenceError: ReadableStream is not defined                                                                                                                                                                      
    at Object.<anonymous> (/home/doshitan/.npm/_npx/3c3b53b86e3a61f2/node_modules/undici/lib/web/fetch/response.js:527:3)                                                                                          
    at Module._compile (node:internal/modules/cjs/loader:1105:14)                                                                                                                                                  
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)                                                                                                                                    
    at Module.load (node:internal/modules/cjs/loader:981:32)                                                                                                                                                       
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)                                                                                                                                             
    at Module.require (node:internal/modules/cjs/loader:1005:19)                                                                                                                                                   
    at require (node:internal/modules/cjs/helpers:102:18)                                                                                                                                                          
    at Object.<anonymous> (/home/doshitan/.npm/_npx/3c3b53b86e3a61f2/node_modules/undici/lib/web/fetch/index.js:11:5)                                                                                              
    at Module._compile (node:internal/modules/cjs/loader:1105:14)                                                                                                                                                  
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)                                                                                                                                    
sh -c 'npx markdown-link-check --config .github/workflows/markdownlint-config.json ./LICENSE.md'                                                                                                                   
/home/doshitan/.npm/_npx/3c3b53b86e3a61f2/node_modules/undici/lib/web/fetch/response.js:527                                                                                                                        
  ReadableStream                                                                                                                                                                                                   
  ^                                                                                                                                                                                                                
                                                                                                                                                                                                                   
ReferenceError: ReadableStream is not defined                                                                                                                                                                      
    at Object.<anonymous> (/home/doshitan/.npm/_npx/3c3b53b86e3a61f2/node_modules/undici/lib/web/fetch/response.js:527:3)                                                                                          
    at Module._compile (node:internal/modules/cjs/loader:1105:14)                                                                                                                                                  
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)                                                                                                                                    
    at Module.load (node:internal/modules/cjs/loader:981:32)                                                                                                                                                       
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)                                                                                                                                             
    at Module.require (node:internal/modules/cjs/loader:1005:19)                                                                                                                                                   
    at require (node:internal/modules/cjs/helpers:102:18)                                                                                                                                                          
    at Object.<anonymous> (/home/doshitan/.npm/_npx/3c3b53b86e3a61f2/node_modules/undici/lib/web/fetch/index.js:11:5)                                                                                              
    at Module._compile (node:internal/modules/cjs/loader:1105:14)                                                                                                                                                  
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10) 

On main

❯ make lint-markdown       
./bin/lint-markdown
npx markdown-link-check --config .github/workflows/markdownlint-config.json ./.github/pull_request_template.md
/home/doshitan/.npm/_npx/3c3b53b86e3a61f2/node_modules/undici/lib/web/fetch/response.js:527
  ReadableStream
  ^

ReferenceError: ReadableStream is not defined
    at Object.<anonymous> (/home/doshitan/.npm/_npx/3c3b53b86e3a61f2/node_modules/undici/lib/web/fetch/response.js:527:3)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/home/doshitan/.npm/_npx/3c3b53b86e3a61f2/node_modules/undici/lib/web/fetch/index.js:11:5)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
npx markdown-link-check --config .github/workflows/markdownlint-config.json ./.github/workflows/README.md
/home/doshitan/.npm/_npx/3c3b53b86e3a61f2/node_modules/undici/lib/web/fetch/response.js:527
  ReadableStream
  ^

ReferenceError: ReadableStream is not defined
    at Object.<anonymous> (/home/doshitan/.npm/_npx/3c3b53b86e3a61f2/node_modules/undici/lib/web/fetch/response.js:527:3)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/home/doshitan/.npm/_npx/3c3b53b86e3a61f2/node_modules/undici/lib/web/fetch/index.js:11:5)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
npx markdown-link-check --config .github/workflows/markdownlint-config.json ./LICENSE.md
/home/doshitan/.npm/_npx/3c3b53b86e3a61f2/node_modules/undici/lib/web/fetch/response.js:527
  ReadableStream
  ^

ReferenceError: ReadableStream is not defined
    at Object.<anonymous> (/home/doshitan/.npm/_npx/3c3b53b86e3a61f2/node_modules/undici/lib/web/fetch/response.js:527:3)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/home/doshitan/.npm/_npx/3c3b53b86e3a61f2/node_modules/undici/lib/web/fetch/index.js:11:5)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)

@doshitan doshitan marked this pull request as ready for review September 30, 2024 16:17
@doshitan
Copy link
Contributor Author

If reviewer could test the npx route that'd be helpful!

@lorenyu
Copy link
Contributor

lorenyu commented Sep 30, 2024

Out today so I'll review this one tomorrow since this one will take me longer to review esp if I'm going to also test it

@doshitan doshitan force-pushed the doshitan/markdown-linting-use-executable-if-present branch from edc9586 to 9d7bf10 Compare October 1, 2024 13:50
Copy link
Contributor

@lorenyu lorenyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late review

Tested the npx route
image

nit to maybe add some documentation at least at the top of bin/lint-markdown for this option (and potentially in set-up-infrastructure-tools.md if you think it would be widely used and doesn't confuse people). Currently it looks to be an undocumented feature

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants